using System;
using System.Collections;

namespace Framework
{
    ///<summary>
    ///</summary>
    public class ColumnCollection : IEnumerable
    {
        private readonly IList _items;

        ///<summary>
        ///</summary>
        public ColumnCollection()
        {
            _items = new ArrayList();
        }

        ///<summary>
        ///</summary>
        ///<param name="column"></param>
        ///<exception cref="ArgumentNullException"></exception>
        ///<exception cref="InvalidOperationException"></exception>
        public void Add(Column column)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }
            if (this._items.Contains(column))
            {
                throw new InvalidOperationException("Column already in collection");
            }

            _items.Add(column);
        }

        ///<summary>
        ///</summary>
        public int Count
        {
            get { return _items.Count; }
        }

        ///<summary>
        ///</summary>
        public Column DefaultDisplayColumn { get; set; }

        ///<summary>
        ///</summary>
        public Column DefaultSortColumn { get; set; }

        ///<summary>
        ///</summary>
        ///<param name="index"></param>
        public Column this[int index]
        {
            get { return (Column)_items[index]; }
        }

        #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            return _items.GetEnumerator();
        }

        #endregion
    } ;
}
